<html>
    <head>
       <style type="text/css">
            .hll { background-color: #ffffcc }
.c { color: #888888 } /* Comment */
.err { color: #a61717; background-color: #e3d2d2 } /* Error */
.k { color: #008800; font-weight: bold } /* Keyword */
.cm { color: #888888 } /* Comment.Multiline */
.cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.c1 { color: #888888 } /* Comment.Single */
.cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #aa0000 } /* Generic.Error */
.gh { color: #333333 } /* Generic.Heading */
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #555555 } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #666666 } /* Generic.Subheading */
.gt { color: #aa0000 } /* Generic.Traceback */
.kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008800 } /* Keyword.Pseudo */
.kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.kt { color: #888888; font-weight: bold } /* Keyword.Type */
.m { color: #0000DD; font-weight: bold } /* Literal.Number */
.s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.na { color: #336699 } /* Name.Attribute */
.nb { color: #003388 } /* Name.Builtin */
.nc { color: #bb0066; font-weight: bold } /* Name.Class */
.no { color: #003366; font-weight: bold } /* Name.Constant */
.nd { color: #555555 } /* Name.Decorator */
.ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.nf { color: #0066bb; font-weight: bold } /* Name.Function */
.nl { color: #336699; font-style: italic } /* Name.Label */
.nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.py { color: #336699; font-weight: bold } /* Name.Property */
.nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.nv { color: #336699 } /* Name.Variable */
.ow { color: #008800 } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.bp { color: #003388 } /* Name.Builtin.Pseudo */
.vc { color: #336699 } /* Name.Variable.Class */
.vg { color: #dd7700 } /* Name.Variable.Global */
.vi { color: #3333bb } /* Name.Variable.Instance */
.il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
        </style>
    </head>
    <body>

<h1>Start up the broker</h1>
<pre>
<div class="highlight"><pre><a name="start.py-pyg.html-1"></a><span class="sd">&quot;&quot;&quot;</span>
<a name="start.py-pyg.html-2"></a><span class="sd">*******************************************************************</span>
<a name="start.py-pyg.html-3"></a><span class="sd">  Copyright (c) 2013, 2014 IBM Corp.</span>
<a name="start.py-pyg.html-4"></a><span class="sd"> </span>
<a name="start.py-pyg.html-5"></a><span class="sd">  All rights reserved. This program and the accompanying materials</span>
<a name="start.py-pyg.html-6"></a><span class="sd">  are made available under the terms of the Eclipse Public License v1.0</span>
<a name="start.py-pyg.html-7"></a><span class="sd">  and Eclipse Distribution License v1.0 which accompany this distribution. </span>
<a name="start.py-pyg.html-8"></a><span class="sd"> </span>
<a name="start.py-pyg.html-9"></a><span class="sd">  The Eclipse Public License is available at </span>
<a name="start.py-pyg.html-10"></a><span class="sd">     http://www.eclipse.org/legal/epl-v10.html</span>
<a name="start.py-pyg.html-11"></a><span class="sd">  and the Eclipse Distribution License is available at </span>
<a name="start.py-pyg.html-12"></a><span class="sd">    http://www.eclipse.org/org/documents/edl-v10.php.</span>
<a name="start.py-pyg.html-13"></a><span class="sd"> </span>
<a name="start.py-pyg.html-14"></a><span class="sd">  Contributors:</span>
<a name="start.py-pyg.html-15"></a><span class="sd">     Ian Craggs - initial implementation and/or documentation</span>
<a name="start.py-pyg.html-16"></a><span class="sd">*******************************************************************</span>
<a name="start.py-pyg.html-17"></a><span class="sd">&quot;&quot;&quot;</span>
<a name="start.py-pyg.html-18"></a>
<a name="start.py-pyg.html-19"></a><span class="kn">import</span> <span class="nn">socketserver</span><span class="o">,</span> <span class="nn">select</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">traceback</span><span class="o">,</span> <span class="nn">socket</span><span class="o">,</span> <span class="nn">logging</span><span class="o">,</span> <span class="nn">getopt</span>
<a name="start.py-pyg.html-20"></a>
<a name="start.py-pyg.html-21"></a><span class="kn">from</span> <span class="nn">.MQTTBrokers</span> <span class="kn">import</span> <span class="n">MQTTBrokers</span>
<a name="start.py-pyg.html-22"></a><span class="kn">from</span> <span class="nn">.coverage</span> <span class="kn">import</span> <span class="n">handler</span><span class="p">,</span> <span class="n">measure</span>
<a name="start.py-pyg.html-23"></a><span class="kn">from</span> <span class="nn">..formats.MQTTV311</span> <span class="kn">import</span> <span class="n">MQTTException</span>
<a name="start.py-pyg.html-24"></a>
<a name="start.py-pyg.html-25"></a><span class="n">broker</span> <span class="o">=</span> <span class="bp">None</span>
<a name="start.py-pyg.html-26"></a><span class="n">server</span> <span class="o">=</span> <span class="bp">None</span>
<a name="start.py-pyg.html-27"></a>
<a name="start.py-pyg.html-28"></a><span class="n">logger</span> <span class="o">=</span> <span class="bp">None</span>
<a name="start.py-pyg.html-29"></a>
<a name="start.py-pyg.html-30"></a><span class="k">class</span> <span class="nc">MyHandler</span><span class="p">(</span><span class="n">socketserver</span><span class="o">.</span><span class="n">StreamRequestHandler</span><span class="p">):</span>
<a name="start.py-pyg.html-31"></a>
<a name="start.py-pyg.html-32"></a>  <span class="k">def</span> <span class="nf">handle</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<a name="start.py-pyg.html-33"></a>    <span class="n">sock</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span>
<a name="start.py-pyg.html-34"></a>    <span class="n">sock_no</span> <span class="o">=</span> <span class="n">sock</span><span class="o">.</span><span class="n">fileno</span><span class="p">()</span>
<a name="start.py-pyg.html-35"></a>    <span class="n">terminate</span> <span class="o">=</span> <span class="n">keptalive</span> <span class="o">=</span> <span class="bp">False</span>
<a name="start.py-pyg.html-36"></a>    <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Starting communications for socket </span><span class="si">%d</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">sock_no</span><span class="p">)</span>
<a name="start.py-pyg.html-37"></a>    <span class="k">while</span> <span class="ow">not</span> <span class="n">terminate</span><span class="p">:</span>
<a name="start.py-pyg.html-38"></a>      <span class="k">try</span><span class="p">:</span>
<a name="start.py-pyg.html-39"></a>        <span class="k">if</span> <span class="ow">not</span> <span class="n">keptalive</span><span class="p">:</span>
<a name="start.py-pyg.html-40"></a>          <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Waiting for request&quot;</span><span class="p">)</span>
<a name="start.py-pyg.html-41"></a>        <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">o</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="o">=</span> <span class="n">select</span><span class="o">.</span><span class="n">select</span><span class="p">([</span><span class="n">sock</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[],</span> <span class="mi">1</span><span class="p">)</span>
<a name="start.py-pyg.html-42"></a>        <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="p">[</span><span class="n">sock</span><span class="p">]:</span>
<a name="start.py-pyg.html-43"></a>          <span class="n">terminate</span> <span class="o">=</span> <span class="n">broker</span><span class="o">.</span><span class="n">handleRequest</span><span class="p">(</span><span class="n">sock</span><span class="p">)</span>
<a name="start.py-pyg.html-44"></a>          <span class="n">keptalive</span> <span class="o">=</span> <span class="bp">False</span>
<a name="start.py-pyg.html-45"></a>        <span class="k">elif</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">o</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="o">==</span> <span class="p">([],</span> <span class="p">[],</span> <span class="p">[]):</span>
<a name="start.py-pyg.html-46"></a>          <span class="n">broker</span><span class="o">.</span><span class="n">keepalive</span><span class="p">(</span><span class="n">sock</span><span class="p">)</span>
<a name="start.py-pyg.html-47"></a>          <span class="n">keptalive</span> <span class="o">=</span> <span class="bp">True</span>
<a name="start.py-pyg.html-48"></a>        <span class="k">else</span><span class="p">:</span>
<a name="start.py-pyg.html-49"></a>          <span class="k">break</span>
<a name="start.py-pyg.html-50"></a>      <span class="k">except</span> <span class="ne">UnicodeDecodeError</span><span class="p">:</span>
<a name="start.py-pyg.html-51"></a>        <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&quot;[MQTT-1.4.0-1] Unicode field encoding error&quot;</span><span class="p">)</span>
<a name="start.py-pyg.html-52"></a>        <span class="k">break</span>
<a name="start.py-pyg.html-53"></a>      <span class="k">except</span> <span class="n">MQTTException</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
<a name="start.py-pyg.html-54"></a>        <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">exc</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<a name="start.py-pyg.html-55"></a>        <span class="k">break</span>
<a name="start.py-pyg.html-56"></a>      <span class="k">except</span> <span class="ne">AssertionError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
<a name="start.py-pyg.html-57"></a>        <span class="k">if</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">exc</span><span class="o">.</span><span class="n">args</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">):</span>
<a name="start.py-pyg.html-58"></a>          <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">exc</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<a name="start.py-pyg.html-59"></a>        <span class="k">else</span><span class="p">:</span>
<a name="start.py-pyg.html-60"></a>          <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">()</span>
<a name="start.py-pyg.html-61"></a>        <span class="k">break</span>
<a name="start.py-pyg.html-62"></a>      <span class="k">except</span><span class="p">:</span>
<a name="start.py-pyg.html-63"></a>        <span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="s">&quot;MyHandler&quot;</span><span class="p">)</span>
<a name="start.py-pyg.html-64"></a>        <span class="k">break</span>
<a name="start.py-pyg.html-65"></a>    <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Finishing communications for socket </span><span class="si">%d</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">sock_no</span><span class="p">)</span>
<a name="start.py-pyg.html-66"></a>
<a name="start.py-pyg.html-67"></a><span class="k">class</span> <span class="nc">ThreadingTCPServer</span><span class="p">(</span><span class="n">socketserver</span><span class="o">.</span><span class="n">ThreadingMixIn</span><span class="p">,</span>
<a name="start.py-pyg.html-68"></a>                           <span class="n">socketserver</span><span class="o">.</span><span class="n">TCPServer</span><span class="p">):</span>
<a name="start.py-pyg.html-69"></a>  <span class="k">pass</span>
<a name="start.py-pyg.html-70"></a>
<a name="start.py-pyg.html-71"></a>
<a name="start.py-pyg.html-72"></a><span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="n">publish_on_pubrel</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">overlapping_single</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">dropQoS0</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<a name="start.py-pyg.html-73"></a>  <span class="k">global</span> <span class="n">logger</span><span class="p">,</span> <span class="n">broker</span><span class="p">,</span> <span class="n">server</span>
<a name="start.py-pyg.html-74"></a>  <span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s">&#39;MQTT broker&#39;</span><span class="p">)</span>
<a name="start.py-pyg.html-75"></a>  <span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
<a name="start.py-pyg.html-76"></a>  <span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">handler</span><span class="p">)</span>
<a name="start.py-pyg.html-77"></a>  <span class="n">port</span> <span class="o">=</span> <span class="mi">1883</span>
<a name="start.py-pyg.html-78"></a>  <span class="n">broker</span> <span class="o">=</span> <span class="n">MQTTBrokers</span><span class="p">(</span><span class="n">publish_on_pubrel</span><span class="o">=</span><span class="n">publish_on_pubrel</span><span class="p">,</span> <span class="n">overlapping_single</span><span class="o">=</span><span class="n">overlapping_single</span><span class="p">,</span> <span class="n">dropQoS0</span><span class="o">=</span><span class="n">dropQoS0</span><span class="p">)</span>
<a name="start.py-pyg.html-79"></a>  <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Starting the MQTT server on port </span><span class="si">%d</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">port</span><span class="p">)</span>
<a name="start.py-pyg.html-80"></a>  <span class="k">try</span><span class="p">:</span>
<a name="start.py-pyg.html-81"></a>    <span class="n">server</span> <span class="o">=</span> <span class="n">ThreadingTCPServer</span><span class="p">((</span><span class="s">&quot;&quot;</span><span class="p">,</span> <span class="n">port</span><span class="p">),</span> <span class="n">MyHandler</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
<a name="start.py-pyg.html-82"></a>    <span class="n">server</span><span class="o">.</span><span class="n">allow_reuse_address</span> <span class="o">=</span> <span class="bp">True</span>
<a name="start.py-pyg.html-83"></a>    <span class="n">server</span><span class="o">.</span><span class="n">server_bind</span><span class="p">()</span>
<a name="start.py-pyg.html-84"></a>    <span class="n">server</span><span class="o">.</span><span class="n">server_activate</span><span class="p">()</span>
<a name="start.py-pyg.html-85"></a>    <span class="n">server</span><span class="o">.</span><span class="n">serve_forever</span><span class="p">()</span>
<a name="start.py-pyg.html-86"></a>  <span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
<a name="start.py-pyg.html-87"></a>    <span class="k">pass</span> 
<a name="start.py-pyg.html-88"></a>  <span class="k">except</span><span class="p">:</span>
<a name="start.py-pyg.html-89"></a>    <span class="n">logger</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="s">&quot;startBroker&quot;</span><span class="p">)</span>
<a name="start.py-pyg.html-90"></a>  <span class="k">finally</span><span class="p">:</span>
<a name="start.py-pyg.html-91"></a>    <span class="k">try</span><span class="p">:</span>
<a name="start.py-pyg.html-92"></a>      <span class="n">server</span><span class="o">.</span><span class="n">socket</span><span class="o">.</span><span class="n">shutdown</span><span class="p">(</span><span class="n">socket</span><span class="o">.</span><span class="n">SHUT_RDWR</span><span class="p">)</span>
<a name="start.py-pyg.html-93"></a>      <span class="n">server</span><span class="o">.</span><span class="n">socket</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<a name="start.py-pyg.html-94"></a>    <span class="k">except</span><span class="p">:</span>
<a name="start.py-pyg.html-95"></a>      <span class="k">pass</span>
<a name="start.py-pyg.html-96"></a>  <span class="n">server</span> <span class="o">=</span> <span class="bp">None</span>
<a name="start.py-pyg.html-97"></a>  <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Stopping the MQTT server on port </span><span class="si">%d</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">port</span><span class="p">)</span>
<a name="start.py-pyg.html-98"></a>  <span class="n">handler</span><span class="o">.</span><span class="n">measure</span><span class="p">()</span>
<a name="start.py-pyg.html-99"></a>  
<a name="start.py-pyg.html-100"></a>
<a name="start.py-pyg.html-101"></a><span class="k">def</span> <span class="nf">stop</span><span class="p">():</span>
<a name="start.py-pyg.html-102"></a>  <span class="k">global</span> <span class="n">server</span>
<a name="start.py-pyg.html-103"></a>  <span class="n">server</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span>
<a name="start.py-pyg.html-104"></a>
<a name="start.py-pyg.html-105"></a><span class="k">def</span> <span class="nf">reinitialize</span><span class="p">():</span>
<a name="start.py-pyg.html-106"></a>  <span class="k">global</span> <span class="n">broker</span>
<a name="start.py-pyg.html-107"></a>  <span class="n">broker</span><span class="o">.</span><span class="n">reinitialize</span><span class="p">()</span>
<a name="start.py-pyg.html-108"></a>
<a name="start.py-pyg.html-109"></a><span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">argv</span><span class="p">):</span>
<a name="start.py-pyg.html-110"></a>  <span class="k">try</span><span class="p">:</span>
<a name="start.py-pyg.html-111"></a>    <span class="n">opts</span><span class="p">,</span> <span class="n">args</span> <span class="o">=</span> <span class="n">getopt</span><span class="o">.</span><span class="n">gnu_getopt</span><span class="p">(</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span> <span class="s">&quot;hp:o:d:&quot;</span><span class="p">,</span> <span class="p">[</span><span class="s">&quot;help&quot;</span><span class="p">,</span> <span class="s">&quot;publish_on_pubrel=&quot;</span><span class="p">,</span> <span class="s">&quot;overlapping_single=&quot;</span><span class="p">,</span> <span class="s">&quot;dropQoS0=&quot;</span><span class="p">])</span>
<a name="start.py-pyg.html-112"></a>  <span class="k">except</span> <span class="n">getopt</span><span class="o">.</span><span class="n">GetoptError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
<a name="start.py-pyg.html-113"></a>    <span class="k">print</span><span class="p">(</span><span class="n">err</span><span class="p">)</span> <span class="c"># will print something like &quot;option -a not recognized&quot;</span>
<a name="start.py-pyg.html-114"></a>    <span class="n">usage</span><span class="p">()</span>
<a name="start.py-pyg.html-115"></a>    <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<a name="start.py-pyg.html-116"></a>  <span class="n">publish_on_pubrel</span> <span class="o">=</span> <span class="n">overlapping_single</span> <span class="o">=</span> <span class="n">dropQoS0</span> <span class="o">=</span> <span class="bp">True</span>
<a name="start.py-pyg.html-117"></a>  <span class="k">for</span> <span class="n">o</span><span class="p">,</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">opts</span><span class="p">:</span>
<a name="start.py-pyg.html-118"></a>    <span class="k">if</span> <span class="n">o</span> <span class="ow">in</span> <span class="p">(</span><span class="s">&quot;-h&quot;</span><span class="p">,</span> <span class="s">&quot;--help&quot;</span><span class="p">):</span>
<a name="start.py-pyg.html-119"></a>      <span class="n">usage</span><span class="p">()</span>
<a name="start.py-pyg.html-120"></a>      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span>
<a name="start.py-pyg.html-121"></a>    <span class="k">elif</span> <span class="n">o</span> <span class="ow">in</span> <span class="p">(</span><span class="s">&quot;-p&quot;</span><span class="p">,</span> <span class="s">&quot;--publish_on_pubrel&quot;</span><span class="p">):</span>
<a name="start.py-pyg.html-122"></a>      <span class="n">publish_on_pubrel</span> <span class="o">=</span> <span class="bp">False</span> <span class="k">if</span> <span class="n">a</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&quot;off&quot;</span><span class="p">,</span> <span class="s">&quot;false&quot;</span><span class="p">,</span> <span class="s">&quot;0&quot;</span><span class="p">]</span> <span class="k">else</span> <span class="bp">True</span>
<a name="start.py-pyg.html-123"></a>    <span class="k">elif</span> <span class="n">o</span> <span class="ow">in</span> <span class="p">(</span><span class="s">&quot;-o&quot;</span><span class="p">,</span> <span class="s">&quot;--overlapping_single&quot;</span><span class="p">):</span>
<a name="start.py-pyg.html-124"></a>      <span class="n">overlapping_single</span> <span class="o">=</span> <span class="bp">False</span> <span class="k">if</span> <span class="n">a</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&quot;off&quot;</span><span class="p">,</span> <span class="s">&quot;false&quot;</span><span class="p">,</span> <span class="s">&quot;0&quot;</span><span class="p">]</span> <span class="k">else</span> <span class="bp">True</span>
<a name="start.py-pyg.html-125"></a>    <span class="k">elif</span> <span class="n">o</span> <span class="ow">in</span> <span class="p">(</span><span class="s">&quot;-d&quot;</span><span class="p">,</span> <span class="s">&quot;--dropQoS0&quot;</span><span class="p">):</span>
<a name="start.py-pyg.html-126"></a>      <span class="n">dropQoS0</span> <span class="o">=</span> <span class="bp">False</span> <span class="k">if</span> <span class="n">a</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&quot;off&quot;</span><span class="p">,</span> <span class="s">&quot;false&quot;</span><span class="p">,</span> <span class="s">&quot;0&quot;</span><span class="p">]</span> <span class="k">else</span> <span class="bp">True</span>
<a name="start.py-pyg.html-127"></a>    <span class="k">else</span><span class="p">:</span>
<a name="start.py-pyg.html-128"></a>      <span class="k">assert</span> <span class="bp">False</span><span class="p">,</span> <span class="s">&quot;unhandled option&quot;</span>
<a name="start.py-pyg.html-129"></a>
<a name="start.py-pyg.html-130"></a>  <span class="n">run</span><span class="p">(</span><span class="n">publish_on_pubrel</span><span class="o">=</span><span class="n">publish_on_pubrel</span><span class="p">,</span> <span class="n">overlapping_single</span><span class="o">=</span><span class="n">overlapping_single</span><span class="p">,</span> <span class="n">dropQoS0</span><span class="o">=</span><span class="n">dropQoS0</span><span class="p">)</span>
<a name="start.py-pyg.html-131"></a>
<a name="start.py-pyg.html-132"></a>
<a name="start.py-pyg.html-133"></a><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span>
<a name="start.py-pyg.html-134"></a>  <span class="n">main</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">)</span>
</pre></div>

</pre>

    </body>
</html>